package GuiPack;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Batch;
import com.badlogic.gdx.graphics.g2d.NinePatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.scenes.scene2d.utils.NinePatchDrawable;

/**
 * Created by Aaron on 8/12/2014.
 */
public class Bar extends Actor {

    private NinePatchDrawable barBackground;

    private NinePatchDrawable barForeground;

    public Bar ( ) {
        Texture texture1 = new Texture("GrassTile32.png");
        Texture texture2 = new Texture("MartianSoil32.png");
        //TextureAtlas atlas = new TextureAtlas(Gdx.files.internal("GrassTile32.png"));
        NinePatch barBackgroundPatch = new NinePatch(texture1, 16, 16, 16, 64);
        NinePatch barForegroundPatch = new NinePatch(texture2, 16, 16, 16, 16);
        this.barBackground = new NinePatchDrawable(barBackgroundPatch);
        this.barForeground = new NinePatchDrawable(barForegroundPatch);
    }

    @Override
    public void draw(Batch batch, float progress) {
        barBackground.draw(batch, getX(), getY(), getWidth() * getScaleX(), getHeight() * getScaleY());
        barForeground.draw(batch, getX(), getY(), progress * getWidth() * getScaleX(), getHeight() * getScaleY());
    }
}
